package com.xgimi.open.skill.datamanager.service.response.page;

import com.baomidou.mybatisplus.core.metadata.IPage;

import java.io.Serializable;

/**
 * @author coderzpw.zhang
 * @version 1.0
 * @description 描述
 * @date 2023/2/4 16:08
 */
public class IPageUtils implements Serializable {
    private static final long serialVersionUID = -6026324244272889223L;

    public IPageUtils() {
    }

    public static Paginator transformToPaginator(IPage iPage) {
        Paginator paginator = new Paginator();
        paginator.setCurrentPage((int)iPage.getCurrent());
        paginator.setPageSize((int)iPage.getSize());
        paginator.setTotalPage((int)iPage.getPages());
        paginator.setTotalRecord((int)iPage.getTotal());
        return paginator;
    }

    public static Paginator noDataPaginator(Integer pageSize) {
        Paginator paginator = new Paginator();
        paginator.setCurrentPage(1);
        paginator.setPageSize(pageSize);
        paginator.setTotalPage(0);
        paginator.setTotalRecord(0);
        return paginator;
    }
}
